package com.cta.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.cta.constant.DiscountType;

@Entity
@Table(name = "cta_tariff_group")
public class TariffGroup implements BaseEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cta_tariff_group_seq")
	@SequenceGenerator(name = "cta_tariff_group_seq", sequenceName = "cta_tariff_group_seq")
	@Column(name = "id", unique = true, nullable = false)
	private Long id;

	@Column(name = "name", unique = true, nullable = false)
	private String name;

	@Column(name = "description", nullable = true)
	private String description;
	
	@Column(name = "discount_type", nullable = false, length = 2)
	private String discountType;
	
	@Column(name = "holiday_discount_value")
	private int holidayDiscountValue;
	
	@Column(name = "first_block")
	private int firstBlock;
	
	@Column(name = "second_block")
	private int secondBlock;
	
	@Column(name = "use_validation")
	private boolean useValidation;
	
	@Column(name = "short_number")
	private int shortNumber;
	
	@Column(name = "long_number")
	private int longNumber;
	
	@Column(name = "currency")
	private String currency;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "tariff_id", nullable = false)
	private TariffRecord tariffRecord;
	
	@OneToMany(fetch = FetchType.LAZY)
	@JoinColumn(name = "tariff_group_id")
	private List<DiscountRate> discountRates;

	public TariffGroup() {
	}
	
	public TariffGroup(Long id) {
		this.id = id;
	}

	public TariffGroup(String name, Long tariffId) {
		this.name = name;
		this.discountType = "L";
		this.tariffRecord = new TariffRecord(tariffId);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public TariffRecord getTariffRecord() {
		return tariffRecord;
	}

	public void setTariffRecord(TariffRecord tariffRecord) {
		this.tariffRecord = tariffRecord;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getHolidayDiscountValue() {
		return holidayDiscountValue;
	}

	public void setHolidayDiscountValue(int holidayDiscountValue) {
		this.holidayDiscountValue = holidayDiscountValue;
	}

	public int getFirstBlock() {
		return firstBlock;
	}

	public void setFirstBlock(int firstBlock) {
		this.firstBlock = firstBlock;
	}

	public int getSecondBlock() {
		return secondBlock;
	}

	public void setSecondBlock(int secondBlock) {
		this.secondBlock = secondBlock;
	}

	public List<DiscountRate> getDiscountRates() {
		return discountRates;
	}

	public void setDiscountRates(List<DiscountRate> discountRates) {
		this.discountRates = discountRates;
	}

	public String getDiscountType() {
		return discountType;
	}

	public void setDiscountType(String discountType) {
		this.discountType = discountType;
	}

	public boolean isUseValidation() {
		return useValidation;
	}

	public void setUseValidation(boolean useValidation) {
		this.useValidation = useValidation;
	}

	public int getShortNumber() {
		return shortNumber;
	}

	public void setShortNumber(int shortNumber) {
		this.shortNumber = shortNumber;
	}

	public int getLongNumber() {
		return longNumber;
	}

	public void setLongNumber(int longNumber) {
		this.longNumber = longNumber;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

}
